import junit.framework.TestCase;



import org.junit.Test;



public class ComplexTest extends TestCase {



    Complex c1 = new Complex(3.0,2.0);



    Complex c2 = new Complex(2.0,2.0);



    Complex c3 = new Complex(2.0,0.0);


    Complex c4 = new Complex(1.0,2.0);



    Complex c5 = new Complex(4.0,2.0);



    Complex c6 = new Complex(4.0,0.0);



    @Test



    public void testComplexAdd() throws Exception {



        assertEquals("5.0+4.0i", c1.ComplexAdd(c2).toString());



        assertEquals("5.0+2.0i", c1.ComplexAdd(c3).toString());



        assertEquals("4.0+2.0i", c2.ComplexAdd(c3).toString());


        assertEquals("5.0+4.0i", c4.ComplexAdd(c5).toString());



        assertEquals("5.0+4.0i", c4.ComplexAdd(c5).toString());



        assertEquals("8.0+2.0i", c5.ComplexAdd(c6).toString());



    }



    @Test



    public void testComplexSub() throws Exception {



        assertEquals("1.0", c1.ComplexSub(c2).toString());



        assertEquals("1.0+2.0i", c1.ComplexSub(c3).toString());



        assertEquals("0.0+2.0i", c2.ComplexSub(c3).toString());



        assertEquals("-1.0", c4.ComplexSub(c2).toString());



        assertEquals("2.0", c6.ComplexSub(c3).toString());



        assertEquals("2.0+2.0i", c5.ComplexSub(c3).toString());



    }



    @Test



    public void testComplexMulti() throws Exception {



        assertEquals("2.0+10.0i", c1.ComplexMulti(c2).toString());



        assertEquals("6.0+4.0i", c1.ComplexMulti(c3).toString());



        assertEquals("4.0+4.0i", c2.ComplexMulti(c3).toString());



        assertEquals("12.0+8.0i", c1.ComplexMulti(c6).toString());



        assertEquals("8.0+4.0i", c5.ComplexMulti(c3).toString());



        assertEquals("4.0", c3.ComplexMulti(c3).toString());



    }



    @Test



    public void testComplexComplexDiv() throws Exception {



        assertEquals("1.25+1.25i", c1.ComplexDiv(c2).toString());



        assertEquals("1.0+1.5i", c1.ComplexDiv(c3).toString());



        assertEquals("1.0+1.0i", c2.ComplexDiv(c3).toString());



        assertEquals("0.5+0.5i", c3.ComplexDiv(c2).toString());



        assertEquals("1.0+2.0i", c5.ComplexDiv(c3).toString());



        assertEquals("1.2+1.2i", c2.ComplexDiv(c4).toString());



    }



    @Test



    public void testEquals() throws Exception{



        assertEquals(false,c1.equals(c2));



        assertEquals(false,c1.equals(c3));



        assertEquals(false,c2.equals(c3));



        assertEquals(true,c1.equals(c1));



    }







}
